<template>
	<el-input v-model="value" v-show="isShow" size="small" :disabled="isReadOnly" :name="field.vModel" clearable
		:counterCode="counterCode" placeholder="流水号"></el-input>
</template>

<script>
	export default {
		name: "f2bpm-serialnum",
		props: ['field', 'fieldvalue'],
		watch: {
			value(val, oleV) {
				var that = this;
				if (val != undefined && oleV != undefined && f2grid_global_mainVueLoadComplated) {
					this.$emit('updatevalue', that.field, val);
				}
			}
		},
		created: function() {
			var that = this;
			that.value = that.fieldvalue;
			var formAction = WFContext.WorkflowformAction;
			var currentActivityType = WFContext.CurrentActivityType;
			var workflowInstinceState = WFContext.WorkflowInstinceState;
			var formAction = WFContext.WorkflowformAction;
			that.isView = formAction > 2;
			if (that.isView) {
				that.isReadOnly = true;
			} else if (that.field._isReadOnly == true) {
				that.isReadOnly = true;
			}

		},
		mounted() {
			var that = this;
			var workflowInstinceState = WFContext.WorkflowInstinceState;
			//只有拟搞或提单时才取序列号
			if (!that.value && (workflowInstinceState == 0 || workflowInstinceState == 1) && formAction <= 2 && that.field
				.inputCtrlOption) {
				var json = typeof that.field.inputCtrlOption == "object" ? that.field.inputCtrlOption : eval("(" + that
					.field.inputCtrlOption + ")");
				if (json.counterCode) {
					that.counterCode = json.counterCode;
					if (WFContext.isDesign == true) {
						return false;
					}
					if ((!that.fieldvalue) && that.counterCode) {
						var result = Object.toAjaxJson(FUI.Handlers.FuiFrameworkHandler, "getSerialNumber", {
							"counterCode": that.counterCode
						});
						if (result.success == true) {
							that.value = result.msg;
							that.$emit('updatevalue', that.field, that.value);
						}
					}
				}
			}



			//FUI.F2Grid.excuteFieldWritePowerByVueFormItem(that);
		},
		data: function() {
			return {
				isView: false,
				isShow: true,
				isReadOnly: false,
				value: '',
				counterCode: ''
			}
		},
		methods: {}
	};
</script>
